package mygob
import (
	"bytes"
	"gitee.com/sky_big/gob_test/server"
	"encoding/gob"
	"fmt"
	"log"
)
type P struct {
	X, Y, Z int
	Name    string
}
type Q struct {
	X, Y *int32
	Name string
}
// This example shows the basic usage of the package: Create an encoder,
// transmit some values, receive them with a decoder.
func Example_basic() {
	// Initialize the encoder and decoder.  Normally enc and dec would be
	// bound to network connections and the encoder and decoder would
	// run in different processes.
	var network bytes.Buffer        // Stand-in for a network connection
	enc := gob.NewEncoder(&network) // Will write to network.

	// Encode (send) some values.
	err := enc.Encode(P{3, 4, 5, "Pythagoras"})
	if err != nil {
		log.Fatal("encode error:", err)
	}
	fmt.Println("enc0=====",network.Bytes())
	err = enc.Encode(P{1782, 1841, 1922, "Treehouse"})
	if err != nil {
		log.Fatal("encode error:", err)
	}
	fmt.Println("enc=====",network.Bytes())
	// Decode (receive) and print the values.
	server.Send(network.Bytes())

	// Output:
	// "Pythagoras": {3, 4}
	// "Treehouse": {1782, 1841}
}